﻿// (c) Copyright slimCODE Software Inc. - www.slimcode.com
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.Collections.Generic;
using System.Text;
using SlimCode.Windows.Controls.Mobile;
using SlimCode.Windows.Forms.Mobile;

namespace SlimCode.SlimPasswords
{
  internal class PasswordSchemeSummaryView : ItemView, IOptionView
  {
    public PasswordSchemeSummaryView()
      : base( string.Empty, ContentAlignmentEx.TopLeft, 3 )
    {
      this.UpdateText();
    }

    public void UpdateText()
    {
      StringBuilder text = new StringBuilder();

      text.Append( "Generate passwords " );
      text.Append( Program.Settings.PasswordScheme.Length );
      text.Append( " chars long, using " );

      if( Program.Settings.PasswordScheme.LowercaseLetters )
      {
        text.Append( "lowercases, " );
      }

      if( Program.Settings.PasswordScheme.UppercaseLetters )
      {
        text.Append( "uppercases, " );
      }

      if( Program.Settings.PasswordScheme.Digits )
      {
        text.Append( "digits, " );
      }

      if( Program.Settings.PasswordScheme.WebSafeSymbols )
      {
        text.Append( "web safe symbols, " );
      }

      if( Program.Settings.PasswordScheme.Symbols )
      {
        text.Append( "symbols, " );
      }

      this.Text = text.ToString().TrimEnd( ' ', ',' ) + ".";
    }

    #region IOptionView Members

    public void Apply()
    {
    }

    public void Cancel()
    {
    }

    public void OnClicked( IScreenHost host, IScreen screen )
    {
      if( host != null )
      {
        host.ShowScreen( new PasswordOptionsScreen() );
      }
    }

    #endregion
  }
}
